package com.group9.handinhand.controller.form;

import java.util.Arrays;
import java.util.List;

import com.group9.handinhand.service.so.CommunitySO;
import com.group9.handinhand.service.so.TagSO;
import com.group9.handinhand.service.so.UserSO;
/**
 * @class CommunityUpdateForm
 * @brief updates the community form
 * */
public class CommunityUpdateForm {
	
	CommunitySO community;/*a community field */
	List<UserSO> moderators; /*a list which includes moderators*/
	String selectedTags;/*tag field which is a string*/
	
	public CommunityUpdateForm() {
		// TODO Auto-generated constructor stub
	}
	/**
	 * A getter method.
	 * @return moderators
	 * */
	public List<UserSO> getModerators() {
		return moderators;
	}
	/**
	 * A setter method.
	 * 
	 * @param moderators
	 * */
	public void setModerators(List<UserSO> moderators) {
		this.moderators = moderators;
	}
	/**
	 * A getter method.
	 * @return community
	 */
	public CommunitySO getCommunity() {
		return community;
	}
	/**
	 * A setter method
	 * @param community
	 */
	public void setCommunity(CommunitySO community) {
		this.community = community;
	}
	/**
	 * A getter method.
	 * @return selectedTags
	 */
	public String getSelectedTags() {
		return selectedTags;
	}
	/**
	 * A setter method.
	 * @param selectedTags
	 */
	public void setSelectedTags(String selectedTags) {
		this.selectedTags = selectedTags;
	}
	/**
	 * A getter method.
	 * @return a list of selected tags
	 */
	public List<String> getSelectedTagsAsList() {
		String[] tags = selectedTags.split(",");
		return Arrays.asList(tags);
	}
	/**
	 * A setter method.
	 * @param soList
	 */
	public void setSelectedTagsFromList(List<TagSO> soList) {
		selectedTags = "";
		if(soList.size()==0)
			return;
		selectedTags += soList.get(0).getTagName();
		soList.remove(0);
		for (TagSO tag : soList) {
			selectedTags += ", " + tag.getTagName();
		}
	}
}
